package com.chaowei.lims.adapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.chaowei.lims.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class BillProgressDetailAdapter extends SimpleAdapter {
	private Context mContxt;
	private ArrayList<HashMap<String, Object>> itemallotList = new ArrayList<HashMap<String,Object>>();
	private LayoutInflater mInflater;
	
	public BillProgressDetailAdapter(Context context,
			List<? extends Map<String, ?>> data, int resource, String[] from,
			int[] to) {
		super(context, data, resource, from, to);
		mContxt = context;
		itemallotList = (ArrayList<HashMap<String, Object>>) data;
		mInflater = LayoutInflater.from(mContxt);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
		if(convertView == null){
			convertView = mInflater.inflate(R.layout.item_progress_listview_detail, null);
			TextView tvSubName = (TextView)convertView.findViewById(R.id.tv_progress_detail_subname);
			TextView tvChkway = (TextView)convertView.findViewById(R.id.tv_progress_detail_chkway);
			TextView tvIssued = (TextView)convertView.findViewById(R.id.tv_progress_detail_issued);
			TextView tvChkstatus = (TextView)convertView.findViewById(R.id.tv_progress_detail_chkstatus);
			holder = new ViewHolder(tvSubName,tvChkway,tvIssued,tvChkstatus);
			convertView.setTag(holder);
		}else{
			holder = (ViewHolder)convertView.getTag();
		}
		
		holder.tvSubname.setText(itemallotList.get(position).get("subname").toString());
		holder.tvChkway.setText(itemallotList.get(position).get("chkway").toString());
		holder.tvIssued.setText(itemallotList.get(position).get("is_assign").toString());
		holder.tvChkstatus.setText(itemallotList.get(position).get("check_status").toString());
		
		return convertView;
	}
	
	private class ViewHolder{
		private TextView tvSubname;
		private TextView tvChkway;
		private TextView tvIssued;
		private TextView tvChkstatus;
		public ViewHolder(TextView tvSubname, TextView tvChkway,
				TextView tvIssued, TextView tvChkstatus) {
			super();
			this.tvSubname = tvSubname;
			this.tvChkway = tvChkway;
			this.tvIssued = tvIssued;
			this.tvChkstatus = tvChkstatus;
		}
		
	
	}

}
